package com.woniu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.woniu.entity.PageData;
import com.woniu.entity.dto.VipDTO;
import com.woniu.pojo.User;
import com.woniu.pojo.Vip;
import com.woniu.mapper.VipMapper;
import com.woniu.service.IUserService;
import com.woniu.service.IVipService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * vip表 服务实现类
 * </p>
 *
 * @author xiaolin
 * @since 2023-04-13
 */
@Service
public class VipServiceImpl extends ServiceImpl<VipMapper, Vip> implements IVipService {

    @Autowired(required = false)
    private VipMapper vipMapper;

    @Override
    public PageData searchPage(Integer currentPage, Integer pageSize, VipDTO vipDTO) {
        IPage<Vip> page = new Page<>(currentPage,pageSize);

        QueryWrapper<Vip> queryWrapper = null;
        if (vipDTO.getName() != null && vipDTO.getName().length() > 0){
            queryWrapper.like("name",vipDTO.getName());
        }

        IPage<Vip> searchPage = vipMapper.selectPage(page,queryWrapper);

        return new PageData(searchPage.getTotal(),searchPage.getRecords());
    }
}
